/**
 * @note 请求雷达
 * @author 吴义迪
 * @create_time 2017-07-06
 */
function requestRadarLayer(id){
	var index = parseInt($("#wu-time-content>.time_li[flag='1']").attr("index"));
	showRadarLayer(id, Config[id].value[index].url);
}

/**
 * @note 展示雷达数据
 * @author 吴义迪
 * @create_time 2017-07-06
 */
function showRadarLayer(id, url){
	var layers = Global.common.map.getLayersByName("layer_"+id+"");
	if(layers.length > 0){
		layers[0].url = url;
		layers[0].redraw();
	}else{
		var bounds = new SuperMap.Bounds(112.566973,43.789980,126.939023,54.569017);
		var layer = new SuperMap.Layer.Image(
			"layer_" + id,
			url,
			bounds,
			{
				numZoomLevels: 18,
				useCanvas: false
			}
		);
		Global.common.map.addLayer(layer);
		layer.setOpacity(parseInt($("#tree_li_"+id+"").attr("opacity")) * 0.01);
		layerIndexControl(layer);
		//雷达定位
//		Global.common.map.zoomToExtent(bounds, true);
		showRaderRing();
	}
}

/**
 * @note 绘制雷达圈
 * @author 吴义迪
 * @create_time 2017-07-06
 */
function showRaderRing(id){
	var layer = new SuperMap.Layer.Vector("radarRing");
	Global.common.map.addLayer(layer);
	layerIndexControl(layer);
	var fs = [];
	var array = [50, 100, 200];
	for(var i=0; i<array.length; i++){
		var point = new SuperMap.Geometry.Point(119.7528,49.2039).transform("EPSG:"+Global.transform.source+"","EPSG:"+Global.transform.dest+"");
		var circleP = createCircle(point,array[i]/110,256,360,360);
		var feature = new SuperMap.Feature.Vector(circleP);
		feature.style = {
			fillOpacity: 0,
			strokeColor: "#000",
	      	strokeWidth: 1
		};
		fs.push(feature);
	}
	layer.addFeatures(fs);
}

/**
 * 绘制圆对象
 * @param {Object} origin
 * @param {Object} radius
 * @param {Object} sides
 * @param {Object} r
 * @param {Object} angel
 * @return {TypeName} 
 */
function createCircle(origin, radius, sides,r,angel){
	var rR = r * Math.PI / (180 * sides);
	var rotatedAngle, x, y;
	var points = [];
	for ( var i = 0; i < sides; ++i) {
		rotatedAngle = rR * i;
		x = origin.x + (radius * Math.cos(rotatedAngle));
		y = origin.y + (radius * Math.sin(rotatedAngle));
		points.push(new SuperMap.Geometry.Point(x, y));
	}
	rotatedAngle = r * Math.PI / 180;
	x = origin.x + (radius * Math.cos(rotatedAngle));
	y = origin.y + (radius * Math.sin(rotatedAngle));
	points.push(new SuperMap.Geometry.Point(x, y));

	var ring = new SuperMap.Geometry.LinearRing(points);
	ring.rotate(parseFloat(angel), origin);
	var geo = new SuperMap.Geometry.Collection( [ ring ]);
	geo.origin = origin;
	geo.radius = radius;
	geo.r = r;
	geo.angel = angel;
	geo.sides = sides;
	geo.polygonType = "Curve";
	return geo;
}